<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Konkurrence</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="">

    <link rel="stylesheet" href="<?php echo $base.$template; ?>fb/css/style-fb.css">
    <link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>

    <script type="text/javascript" src="<?php echo $base.$template; ?>fb/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        WebFontConfig = {
            google: { families: [ 'Oswald:400,700:latin' ] }
        };
        (function() {
            var wf = document.createElement('script');
            wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
                '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
            wf.type = 'text/javascript';
            wf.async = 'true';
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(wf, s);
        })();
    </script>
</head>
<body>
<?php if(!$liked){ ?>
    <div class="wrapper konkurrence-1">
        <div class="header clear-fix">
            <h2><a href="<?php echo $base ?>"><img src="<?php echo $base.$template ?>fb/img/logo.png"></a></h2>
            <h1 class="clear-fix">
                <a href="javascript:void(0);">Tryk <span class="colorX">"Syntes godt om"</span> øverst til højre, og deltag i månedens tkonkurrence</a>
                <img src="<?php echo $base.$template ?>fb/img/iconArrow.png" alt="">
            </h1>
        </div>

        <div class="content clear-fix">
            <div class="inner clear-fix">
                <?php echo $description; ?>
            </div>
        </div>
    </div>
<?php }elseif($newsletter_form){ ?>
    <div class="wrapper newsletter">
        <div class="header clear-fix">
            <h2><a href="#"><img src="<?php echo $base.$template ?>fb/img/logo.png"></a></h2>
            <!-- div class="divicon"><a href="#"><img src="<?php echo $base.$template ?>fb/img/iconDel.png" alt=""></a></div-->
        </div>
        <div class="content clear-fix">
            <div class="inner clear-fix">
                <?php echo  $description2; ?>

                <form id="f-newsletter">
                    <fieldset>
                        <div class="wrap-from">
                            <input type="text" id="name" name="name" class="txtInput" placeholder="Indtast din navn...">
                            <input type="text" id="email" name="email" class="txtInput" placeholder="Indtast din e-mail......">
                            <a id="subscriber_button" href="javascript:void(0);" class="button buttonNext">
                                Tilmeld nu
                                <img src="<?php echo $base.$template ?>img/iconbtn.png" alt=""/>
                            </a>
                        </div>
                    </fieldset>
                </form>
            </div> <!--inner-->
        </div><!--content-->
    </div><!--wrapper-->
<?php }else{ ?>
    <div class="wrapper konkurrence-2">
        <div class="content clear-fix">
            <!-- div class="divicon"><a href="#"><img src="<?php echo $base.$template ?>img/iconDel.png" alt=""></a></div -->
            <div class="inner clear-fix">
                <?php echo $description1; ?>

                <form id="f-newsletter">
                    <fieldset>
                        <div class="wrap-from">
                            <input type="text" id="name" name="name" class="txtInput" placeholder="Indtast din navn...">
                            <input type="text" id="email" name="email" class="txtInput" placeholder="Indtast din e-mail......">
                            <a id="subscriber_button" href="javascript:void(0);" class="button buttonNext">
                                Deltag
                                <img src="<?php echo $base.$template ?>img/iconbtn.png" alt=""/>
                            </a>
                        </div>
                    </fieldset>
                </form>
            </div> <!--inner-->
        </div><!--content-->
    </div><!--wrapper-->
<?php } ?>

<script type="text/javascript">
    var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,6})+$/;

    $(document).ready(function(){
        $('#subscriber_button').on('click', function(e){
            e.preventDefault();

            if($('#name').val() == ''){
                showPopup('Navn er ugyldig. Indtast en gyldig navn.');

                return false;
            }

            if(!mail_filter.test(jQuery('#email').val())){
                showPopup('E-mailen er ugyldig. Indtast en gyldig e-mail.');

                return false;
            }

            $.ajax({
                type: "POST",
                url: "<?php echo $subscriber ?>",
                data: jQuery('#f-newsletter').serialize(),
                dataType: "text",
                success: function(data){
                    if(data == 'Tak for tilmelding vores konkurrence'){
                        $('#f-newsletter')[0].reset();
                    }

                    showPopup(data);
                }
            });
        });
    });

    function showPopup(msg){
        alert(msg);
    }
</script>
</body>
</html>